<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
 <%@page import="sdfi.lee.Entity.Person"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="sdfi.lee.DAO.PersonDAO"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="<c:url value='/css/common.css'></c:url>">
<script type="text/javascript" src="<c:url value='/js/jquery-1.6.js'></c:url>"></script>
<script>
	$(function(){
			
		$('div a img').css("width","100px").css("height","100px");
		$('div.hehe>div:nth-child(5n+1)').addClass('personitem1');
		$('div.hehe>div:nth-child(5n+2)').addClass('personitem1');
		$('div.hehe>div:nth-child(5n+3)').addClass('personitem1');
		$('div.hehe>div:nth-child(5n+4)').addClass('personitem1');
		$('div.hehe>div:nth-child(5n+5)').addClass('personitem2');
		$('div :button').click(function(){
			var b=$(this);
			var option={
	  				success:function(data,status){
	  				b.parent("div").remove();
					$('div.hehe>div:nth-child(5n+1)').addClass('personitem1').removeClass('personitem2');
					$('div.hehe>div:nth-child(5n+2)').addClass('personitem1').removeClass('personitem2');
					$('div.hehe>div:nth-child(5n+3)').addClass('personitem1').removeClass('personitem2');
					$('div.hehe>div:nth-child(5n+4)').addClass('personitem1').removeClass('personitem2');
					$('div.hehe>div:nth-child(5n+5)').addClass('personitem2').removeClass('personitem1');
	  			},
	  			error:function(xhr,status){
	  				alert(xhr.status);
	  			},
	  			url:"../DeletePerson",
	  			data:{personid:$(this).val()},
	  			dataType:"json"
	  		};
			$.ajax(option);
			
			});
			
	});
</script>
<title></title>
</head>
<body>
<div class="hehe">
<%
 	java.util.List<Person> list=new PersonDAO()
.getAllPerson(Integer.valueOf(request.getParameter("pg")),5,Integer.valueOf(request.getParameter("ptype")));
	
	if(null!=list&&list.size()>0)
	{
			request.setAttribute("list",list);
			
%>
	
		<c:forEach items="${requestScope.list}" var="person">
		
			<div>
				<c:url var="personurl" value="/admin/personmf.jsp">
					<c:param name="personid" value="${person.id}"></c:param>
				</c:url>
				<div><a href="${personurl}"><img src="${person.personPath}" /></a></div>
				<div><a href="${personurl}">${person.personname}</a></div>
				<button value="${person.id}">x</button>
			</div>
		</c:forEach>
			
	<%
	}
	else
	{
	%>
	无数据
	<%
	}
	%>
		</div>
		<div id="pages">
			<!-- 上一页 -->
			<c:url value="/admin/personmg.jsp?pg=${param.pg-1}&ptype=${param.ptype}" var="up"></c:url>
			<!-- 下一页-->
			<c:url value="/admin/personmg.jsp?pg=${param.pg+1}&ptype=${param.ptype}" var="down"></c:url>
			<font>
					<c:choose>
						<c:when test="${param.pg==1}">&lt;</c:when>
						<c:otherwise><a href="${up}">&lt;</a></c:otherwise>
					</c:choose>
			</font>
			<font>
				 ${param.pg}
			</font>
			<font>
				<c:choose>
					<c:when test="${fn:length(requestScope.list)<5}">
						&gt;
					</c:when>
					<c:otherwise>
				<a href="${down}">&gt;</a>
					</c:otherwise>
				</c:choose>
			</font>
	</div>
		
</html>